home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CU Amiga Super CD-ROM 11
/
CU Amiga Magazine's Super CD-ROM 11 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-06].iso
/
cucd
/
programming
/
oberonv4
/
source
/
system
/
amigados.mod
(
.txt
)
< prev
next >
Wrap
Oberon Text
|
1996-06-09
|
11KB
|
362 lines
Syntax10.Scn.Fnt
Syntax10b.Scn.Fnt
Syntax12b.Scn.Fnt
MODULE AmigaDos; (*shml/cn/FF/RD/OJ *)
(* Danger: RETURN of open Array in FilePart() is still hacky! *)
IMPORT
SYSTEM, E:=AmigaExec, U := AmigaUtility;
dosBase- : E.LibraryPtr;
dosVersion- : INTEGER;
termEntry : E.TermEntry;
dummy : LONGINT;
CONST
dosName*="dos.library";
beginning*=-1;
end*=1;
newFile*=1006;
oldFile*=1005;
readWrite*=1004;
objectInUse*=202;
renameAcrossDevices*=215;
same*=0;
sharedLock*=-2;
ticksPerSecond*=50;
globalOnly*=8;
binaryVar*=10;
dontNullTerm*=11;
saveVar*=12;
protDelete*=0;
protExecute*=1;
protWrite*=2;
protRead*=3;
protArchive*=4;
protPure*=5;
protScript*=6;
Some Pointer without their records
CommandLineInterfacePtr=LONGINT;
ProcessId=LONGINT;
Date*=RECORD
days*:LONGINT;
minute*:LONGINT;
tick*:LONGINT
END;
FileHandlePtr*=LONGINT; (* NOTE: This is a BPTR *)
FileLockPtr*=LONGINT; (* NOTE: This is a BPTR *)
FileInfoBlock*=RECORD
diskKey*:LONGINT;
dirEntryType*:LONGINT;
fileName*:ARRAY 108 OF CHAR;
protection*:SET;
entryType*:LONGINT;
size*:LONGINT;
numBlock*:LONGINT;
date*:Date;
comment*:ARRAY 80 OF CHAR;
ownerUID*:INTEGER;
ownerGID*:INTEGER;
reserved*:ARRAY 32 OF CHAR
END;
FileInfoBlockPtr*=LONGINT;
Process*=RECORD
task*:E.Task;
msgPort*:E.MsgPort;
pad*:INTEGER;
segList*:LONGINT;
stackSize*:LONGINT;
globVec*:LONGINT;
taskNum*:LONGINT;
stackBase*:LONGINT;
result2*:LONGINT;
currentDir*:FileLockPtr;
cis*:FileHandlePtr;
cos*:FileHandlePtr;
consoleTask*:ProcessId;
fileSystemTask*:ProcessId;
cli*:CommandLineInterfacePtr;
returnAddr*:LONGINT;
pktWait*:LONGINT;
windowPtr*:LONGINT;
homeDir*:FileLockPtr;
flags*:SET;
exitCode*:LONGINT;
exitData*:LONGINT;
arguments*:LONGINT;
localVars*:E.MinList;
shellPrivate*:LONGINT;
ces*:FileHandlePtr
END;
CONST
sysDummy*=U.user+32;
sysInput*=sysDummy+1;
sysOutput*=sysDummy+2;
sysASynch*=sysDummy+3;
sysUserShell*=sysDummy+4;
sysCustomShell*=sysDummy+5;
npDummy*=U.user+1000;
npCloseOutput*=npDummy+7;
PROCEDURE -ReturnD0 04EH,05EH, 04EH,075H;
PROCEDURE AddPart*(VAR dir : ARRAY OF CHAR; filename : ARRAY OF CHAR; size:LONGINT) : BOOLEAN;
BEGIN
dummy := SYSTEM.ADR(filename);
SYSTEM.PUTREG( 1, SYSTEM.ADR(dir) );
SYSTEM.PUTREG( 2, dummy );
SYSTEM.PUTREG( 3, size );
SYSTEM.CALL( -882, dosBase );
SYSTEM.GETREG( 0, dummy );
RETURN dummy#E.false
END AddPart;
PROCEDURE AllocDosObject*(type, tags: LONGINT): LONGINT;
BEGIN
SYSTEM.PUTREG( 1, type );
SYSTEM.PUTREG( 2, tags );
SYSTEM.CALL(-228, dosBase);
ReturnD0
END AllocDosObject;
PROCEDURE Close*(file:FileHandlePtr):BOOLEAN;
BEGIN
SYSTEM.PUTREG( 1, file );
SYSTEM.CALL( -36, dosBase );
SYSTEM.GETREG( 0, dummy );
RETURN dummy#E.false
END Close;
PROCEDURE CurrentDir*(lock: FileLockPtr):FileLockPtr;
BEGIN
SYSTEM.PUTREG( 1, lock );
SYSTEM.CALL( -126, dosBase );
ReturnD0
END CurrentDir;
PROCEDURE CreateDir*(name: ARRAY OF CHAR): FileLockPtr;
BEGIN
SYSTEM.PUTREG( 1, SYSTEM.ADR(name) );
SYSTEM.CALL( -120, dosBase );
ReturnD0
END CreateDir;
PROCEDURE DateStamp*(VAR date:Date);
BEGIN
SYSTEM.PUTREG( 1, SYSTEM.ADR(date) );
SYSTEM.CALL( -192, dosBase )
END DateStamp;
PROCEDURE Delay*(w: LONGINT);
BEGIN
SYSTEM.PUTREG( 1, w );
SYSTEM.CALL( -198, dosBase )
END Delay;
PROCEDURE DeleteFile*(name:ARRAY OF CHAR):BOOLEAN;
BEGIN
SYSTEM.PUTREG( 1, SYSTEM.ADR(name) );
SYSTEM.CALL( -72, dosBase );
SYSTEM.GETREG( 0, dummy );
RETURN dummy#0
END DeleteFile;
PROCEDURE DupLockFromFH*(fh:FileHandlePtr):FileLockPtr;
BEGIN
SYSTEM.PUTREG( 1, fh );
SYSTEM.CALL( -372, dosBase );
ReturnD0
END DupLockFromFH;
PROCEDURE Examine*(lock:FileLockPtr; VAR info:FileInfoBlock):BOOLEAN;
(* NOTE: info has to be longword aligned. *)
BEGIN
SYSTEM.PUTREG( 1, lock );
SYSTEM.PUTREG( 2, SYSTEM.ADR(info) );
SYSTEM.CALL( -102, dosBase );
SYSTEM.GETREG( 0, dummy );
RETURN dummy#0
END Examine;
PROCEDURE ExNext*(lock: FileLockPtr; VAR info: FileInfoBlock): BOOLEAN;
BEGIN
SYSTEM.PUTREG( 1, lock );
SYSTEM.PUTREG( 2, SYSTEM.ADR(info) );
SYSTEM.CALL( -108, dosBase );
SYSTEM.GETREG( 0, dummy );
RETURN dummy#0
END ExNext;
PROCEDURE FGets*(fh: FileHandlePtr; VAR buf: ARRAY OF CHAR; buflen: LONGINT): LONGINT;
BEGIN
SYSTEM.PUTREG( 1, fh );
SYSTEM.PUTREG( 2, SYSTEM.ADR(buf) );
SYSTEM.PUTREG( 3, buflen );
SYSTEM.CALL( -336, dosBase );
ReturnD0
END FGets;
PROCEDURE FilePart*(VAR path, fileName: ARRAY OF CHAR);
VAR p: POINTER TO ARRAY 1 OF CHAR;
BEGIN
SYSTEM.PUTREG( 1, SYSTEM.ADR(path) );
SYSTEM.CALL( -870, dosBase );
SYSTEM.GETREG( 0, p );
COPY(p^, fileName)
END FilePart;
PROCEDURE FreeDosObject*(type: LONGINT; ptr: LONGINT);
BEGIN
SYSTEM.PUTREG( 1, type );
SYSTEM.PUTREG( 2, ptr );
SYSTEM.CALL( -234, dosBase )
END FreeDosObject;
PROCEDURE GetCurrentDirName*(VAR buf: ARRAY OF CHAR; len: LONGINT): BOOLEAN;
BEGIN
SYSTEM.PUTREG( 1, SYSTEM.ADR(buf) );
SYSTEM.PUTREG( 2, len );
SYSTEM.CALL( -564, dosBase );
SYSTEM.GETREG( 0, dummy);
RETURN dummy#0
END GetCurrentDirName;
PROCEDURE GetVar*(name:ARRAY OF CHAR; buffer:LONGINT; size:LONGINT; flags:SET):LONGINT;
BEGIN
SYSTEM.PUTREG( 1, SYSTEM.ADR(name) );
SYSTEM.PUTREG( 2, buffer );
SYSTEM.PUTREG( 3, size );
SYSTEM.PUTREG( 4, flags );
SYSTEM.CALL( -906, dosBase );
ReturnD0
END GetVar;
PROCEDURE IoErr*():LONGINT;
BEGIN
SYSTEM.CALL( -132, dosBase );
ReturnD0
END IoErr;
PROCEDURE Lock*(name:ARRAY OF CHAR; type:LONGINT):FileLockPtr;
BEGIN
SYSTEM.PUTREG( 1, SYSTEM.ADR(name) );
SYSTEM.PUTREG( 2, type );
SYSTEM.CALL( -84, dosBase );
ReturnD0
END Lock;
PROCEDURE NameFromFH*(fh:FileHandlePtr; VAR name:ARRAY OF CHAR):BOOLEAN;
BEGIN
dummy := LEN(name);
SYSTEM.PUTREG( 2, SYSTEM.ADR(name) );
SYSTEM.PUTREG( 3, dummy );
SYSTEM.PUTREG( 1, fh );
SYSTEM.CALL( -408, dosBase );
SYSTEM.GETREG( 0, dummy );
RETURN dummy#0
END NameFromFH;
PROCEDURE NameFromLock*(lock:FileLockPtr; VAR name:ARRAY OF CHAR):BOOLEAN;
BEGIN
dummy := LEN(name);
SYSTEM.PUTREG( 2, SYSTEM.ADR(name) );
SYSTEM.PUTREG( 3, dummy );
SYSTEM.PUTREG( 1, lock );
SYSTEM.CALL( -402, dosBase );
SYSTEM.GETREG( 0, dummy );
RETURN dummy#0
END NameFromLock;
PROCEDURE Open*(name:ARRAY OF CHAR; accessMode:LONGINT):FileHandlePtr;
BEGIN
SYSTEM.PUTREG( 1, SYSTEM.ADR(name) );
SYSTEM.PUTREG( 2, accessMode );
SYSTEM.CALL( -30, dosBase );
ReturnD0
END Open;
PROCEDURE Output*():FileHandlePtr;
BEGIN
SYSTEM.CALL( -60, dosBase );
ReturnD0
END Output;
PROCEDURE Read*(file:FileHandlePtr; VAR buffer:ARRAY OF SYSTEM.BYTE; length:LONGINT):LONGINT;
BEGIN
SYSTEM.PUTREG( 2, SYSTEM.ADR(buffer) );
SYSTEM.PUTREG( 1, file );
SYSTEM.PUTREG( 3, length );
SYSTEM.CALL( -42, dosBase );
ReturnD0
END Read;
PROCEDURE Rename*(oldName,newName:ARRAY OF CHAR):BOOLEAN;
BEGIN
dummy := SYSTEM.ADR(newName);
SYSTEM.PUTREG( 1, SYSTEM.ADR(oldName) );
SYSTEM.PUTREG( 2, dummy );
SYSTEM.CALL( -78, dosBase );
SYSTEM.GETREG( 0, dummy );
RETURN dummy#0
END Rename;
PROCEDURE SameLock*(lock1,lock2:FileLockPtr):LONGINT;
BEGIN
SYSTEM.PUTREG( 1, lock1 );
SYSTEM.PUTREG( 2, lock2 );
SYSTEM.CALL( -420, dosBase );
ReturnD0
END SameLock;
PROCEDURE Seek*(file:FileHandlePtr; position,mode:LONGINT):LONGINT;
BEGIN
SYSTEM.PUTREG( 1, file );
SYSTEM.PUTREG( 2, position );
SYSTEM.PUTREG( 3, mode );
SYSTEM.CALL( -66, dosBase );
SYSTEM.GETREG( 0, dummy );
IF (dosVersion<39) & (IoErr()#0) THEN dummy:=-1 END; (* OS2.x-Bug! *)
RETURN dummy
END Seek;
PROCEDURE SetCurrentDirName*(name: ARRAY OF CHAR): BOOLEAN;
BEGIN
SYSTEM.PUTREG( 1, SYSTEM.ADR(name) );
SYSTEM.CALL( -558, dosBase );
SYSTEM.GETREG(0, dummy);
RETURN dummy#0
END SetCurrentDirName;
PROCEDURE SetFileSize*(fh:FileHandlePtr; offset,mode:LONGINT):LONGINT;
BEGIN
SYSTEM.PUTREG( 1, fh );
SYSTEM.PUTREG( 2, offset );
SYSTEM.PUTREG( 3, mode );
SYSTEM.CALL( -456, dosBase );
ReturnD0
END SetFileSize;
PROCEDURE SetProtection*(name:ARRAY OF CHAR; mask:SET):BOOLEAN;
BEGIN
SYSTEM.PUTREG( 1, SYSTEM.ADR(name) );
SYSTEM.PUTREG( 2, mask );
SYSTEM.CALL( -186, dosBase );
SYSTEM.GETREG( 0, dummy );
RETURN dummy#0
END SetProtection;
PROCEDURE SetVar*(name:ARRAY OF CHAR; buffer:LONGINT; size:LONGINT; flags:SET):BOOLEAN;
BEGIN
SYSTEM.PUTREG( 1, SYSTEM.ADR(name) );
SYSTEM.PUTREG( 2, buffer );
SYSTEM.PUTREG( 3, size );
SYSTEM.PUTREG( 4, flags );
SYSTEM.CALL( -900, dosBase );
SYSTEM.GETREG( 0, dummy );
RETURN dummy#0
END SetVar;
PROCEDURE System*(command:ARRAY OF CHAR; VAR tagList:ARRAY OF U.TagItem):LONGINT;
BEGIN
dummy := SYSTEM.ADR(tagList);
SYSTEM.PUTREG( 1, SYSTEM.ADR(command) );
SYSTEM.PUTREG( 2, dummy );
SYSTEM.CALL( -606, dosBase );
ReturnD0
END System;
PROCEDURE UnLock*(lock:FileLockPtr);
BEGIN
SYSTEM.PUTREG( 1, lock );
SYSTEM.CALL( -90, dosBase )
END UnLock;
PROCEDURE Write*(file:FileHandlePtr; VAR buffer:ARRAY OF SYSTEM.BYTE; length:LONGINT):LONGINT;
BEGIN
SYSTEM.PUTREG( 2, SYSTEM.ADR(buffer) );
SYSTEM.PUTREG( 1, file );
SYSTEM.PUTREG( 3, length );
SYSTEM.CALL( -48, dosBase );
ReturnD0
END Write;
PROCEDURE Init;
TYPE LibraryPtr=POINTER TO E.Library;
VAR lib:LibraryPtr;
BEGIN
dosBase:=E.OpenLibrary(dosName,37);
IF dosBase=0 THEN HALT(99) END;
lib:=SYSTEM.VAL(LibraryPtr,dosBase);
dosVersion:=lib.version
END Init;
PROCEDURE Term;
BEGIN
E.CloseLibrary( dosBase )
END Term;
BEGIN
Init;
E.Register(termEntry, Term)
END AmigaDos.